package com.ruboweb.domain;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;

import com.sun.xml.internal.txw2.annotation.XmlCDATA;

/**
 * Mapeo de la estidad Query del XML
 */
public class Consulta {

	/**
	 * Nombre de la consulta
	 */
	@XmlAttribute
	private String consulta;

	/**
	 * Consulta SQL a ejecutar
	 */
	@XmlValue
	private String query;

	/**
	 * Constructor de la clase
	 */
	public Consulta() {

	}

	/* Gets */

	public String getConsulta() {
		return this.consulta;
	}

	@XmlCDATA
	public String getQuery() {
		this.query = this.query.replaceAll("\t", "");
		this.query = this.query.replaceAll("\n", "");
		
		this.query = this.query.replaceAll("#T#", "\t");
		this.query = this.query.replaceAll("#N#", "\n");
		return this.query;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String toString() {
		return "Consulta [consulta=" + consulta + ", query=" + query + "]";
	}

}
